<?php TPL::output('admin/global/header.tpl.htm'); ?>
<?php TPL::output('admin/global/nav_menu.tpl.htm'); ?>

<div class="aw-content-wrap">
    <div class="mod">
        <div class="mod-head">
            <h3>
                <?php if ($this->account_info) { ?>
                <span class="pull-left"><?php _e('编辑公众账号'); ?></span>
                <?php } else { ?>
                <ul class="nav nav-tabs">
                    <li><a href="admin/weixin/accounts/"><?php _e('账号列表'); ?></a></li>
                    <li class="active"><a href="admin/weixin/account/"><?php _e('新增账号'); ?></a></li>
                </ul>
                <?php } ?>
            </h3>
        </div>

        <div class="tab-content mod-content">
        <form action="admin/ajax/weixin/save_account/" id="account_form" method="post" onsubmit="return false">
        <table class="table table-striped">
            <input name="type" type="hidden" value="<?php if ($this->account_info) { ?>update<?php } else { ?>add<?php } ?>" />

            <?php if ($this->account_info) { ?>
            <input name="id" type="hidden" value="<?php echo $this->account_info['id']; ?>" />
            <?php } ?>

            <tr>
                <td>
                    <div class="form-group">
                    <span class="col-sm-4 col-xs-3 control-label"><?php _e('微信公众平台接口 Token'); ?>:</span>
                    <div class="col-sm-5 col-xs-8">
                        <input type="text" class="form-control" name="weixin_mp_token" value="<?php if ($this->account_info) echo $this->account_info['weixin_mp_token']; ?>">
                        <span class="help-block"><?php
                        if ($this->account_info) {
                            _e('请与微信公众平台后台设置一致，URL 为 <code>%s</code>', get_js_url('/weixin/api/' . $this->account_info['id']));
                        } else {
                            _e('请与微信公众平台后台设置一致');
                        };
                        ?></span>
                    </div>
                    </div>
                </td>
            </tr>

            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label"><?php _e('微信公众平台接口 EncodingAESKey'); ?>:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="text" class="form-control" name="weixin_encoding_aes_key" value="<?php if ($this->account_info) echo $this->account_info['weixin_encoding_aes_key']; ?>">
                        </div>
                    </div>
                </td>
            </tr>

            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label"><?php _e('微信公众平台帐号角色'); ?>:</span>
                        <div class="col-sm-8 col-xs-8">
                            <label class="checkbox-inline">
                                <input type="radio" name="weixin_account_role" value="base"<?php if (!$this->account_info OR $this->account_info['weixin_account_role'] == 'base') { ?> checked="checked"<?php } ?> />
                                <?php _e('普通订阅号'); ?>
                            </label>

                            <label class="checkbox-inline">
                                <input type="radio" name="weixin_account_role" value="subscription"<?php if ($this->account_info AND $this->account_info['weixin_account_role'] == 'subscription') { ?> checked="checked"<?php } ?> />
                                <?php _e('微信认证订阅号'); ?>
                            </label>

                            <label class="checkbox-inline">
                                <input type="radio" name="weixin_account_role" value="general"<?php if ($this->account_info AND $this->account_info['weixin_account_role'] == 'general') { ?> checked="checked"<?php } ?> />
                                <?php _e('普通服务号'); ?>
                            </label>

                            <label class="checkbox-inline">
                                <input type="radio" name="weixin_account_role" value="service"<?php if ($this->account_info AND $this->account_info['weixin_account_role'] == 'service') { ?> checked="checked"<?php } ?> />
                                <?php _e('微信认证服务号'); ?>
                        </label>
                        </div>
                    </div>
                </td>
            </tr>

            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label"><?php _e('微信公众平台 AppID'); ?>:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="text" class="form-control" name="weixin_app_id" value="<?php if ($this->account_info) echo $this->account_info['weixin_app_id']; ?>">
                        </div>
                    </div>
                </td>
            </tr>

            <tr>
                <td>
                    <div class="form-group">
                        <span class="col-sm-4 col-xs-3 control-label"><?php _e('微信公众平台 AppSecret'); ?>:</span>
                        <div class="col-sm-5 col-xs-8">
                            <input type="text" class="form-control" name="weixin_app_secret" value="<?php if ($this->account_info) echo $this->account_info['weixin_app_secret']; ?>">
                        </div>
                    </div>
                </td>
            </tr>

            <tfoot>
            <tr>
                <td>
                    <input type="button" value="<?php _e('保存设置'); ?>" class="btn btn-primary center-block" onclick="AWS.ajax_post($('#account_form'));" />
                </td>
            </tr>
            </tfoot>
        </table>
        </form>
        </div>
    </div>
</div>

<?php TPL::output('admin/global/footer.tpl.htm'); ?>